# zlib.cmake
# 本文件包含着从外部导入 zlib 所需要的信息

INCLUDE(ExternalProject)

set(ZLIB_ROOT ${PROJECT_SOURCE_DIR}/extern_module_download/zlib)
set(ZLIB_GIT_URL      https://atomgit.com/dangaldb/Zlib-Mirror.git)  # 指定git仓库地址
set(ZLIB_CONFIGURE    cd ${ZLIB_ROOT}/src/extern_zlib/ && cmake -D CMAKE_INSTALL_PREFIX=${ZLIB_ROOT}/output .)
set(ZLIB_MAKE         cd ${ZLIB_ROOT}/src/extern_zlib && make)
set(ZLIB_INSTALL      cd ${ZLIB_ROOT}/src/extern_zlib && make install) 

ExternalProject_Add(extern_zlib
        PREFIX            ${ZLIB_ROOT}
        GIT_REPOSITORY    ${ZLIB_GIT_URL}
        CONFIGURE_COMMAND ${ZLIB_CONFIGURE}
        BUILD_COMMAND     ${ZLIB_MAKE}
        INSTALL_COMMAND   ${ZLIB_INSTALL}
        CMAKE_ARGS
        -DCMAKE_INSTALL_PREFIX=${ZLIB_ROOT}/output
        -DBUILD_SHARED_LIBS=OFF
)

INCLUDE_DIRECTORIES(${ZLIB_ROOT}/output/include)
LINK_DIRECTORIES(${ZLIB_ROOT}/output/lib)
